package de.szut.util;

/**
 * Utility class for checking if a value is in a certain range
 * @author Marc Huisinga
 *
 */
public final class RangeCheck {
	
	/**
	 * Checks if the value is in the specified range inclusively (returns true if value equals min or max) 
	 * @param min - Minimum
	 * @param max - Maximum
	 * @param value - Value to be checked
	 * @return result
	 */
	public static boolean isInRangeInclusive(Number min, Number max, Number value) {
		double realValue = value.doubleValue();
		return realValue>=min.doubleValue() && realValue<=max.doubleValue();
	}
	
	/**
	 * Checks if the value is in the specified range exclusively (returns false if value equals min or max) 
	 * @param min - Minimum
	 * @param max - Maximum
	 * @param value - Value to be checked
	 * @return result
	 */
	public static boolean isInRangeExclusive(Number min, Number max, Number value) {
		double realValue = value.doubleValue();
		return realValue>min.doubleValue() && realValue<max.doubleValue();
	}
	
	/**
	 * Checks if the value is in the specified range with min being inclusive and max being exclusive 
	 * (returns true if value equals min but equals false if value equals max) 
	 * @param min - Minimum
	 * @param max - Maximum
	 * @param value - Value to be checked
	 * @return result
	 */
	public static boolean isInRange(Number min, Number max, Number value) {
		double realValue = value.doubleValue();
		return realValue>=min.doubleValue() && realValue<max.doubleValue();
	}
	
	private RangeCheck() {}
}
